package Mystack;

import java.util.Stack;

public class teat1 {
    //括号匹配
    public static void main(String[] args) {
        String str = "({([])}))";
        Stack<Character> stack = new Stack<>();
        int i = 0;
        for (; i < str.length(); i++) {
            char c = str.charAt(i);
            if (c == '(' || c == '{' || c == '[') {
                stack.push(c);
            } else {
                if (stack.isEmpty()) {
                    System.out.println("false");
                    return;
                }
                char peek = stack.peek();

                if (peek == '(' && c == ')' || peek == '{' && c == '}' || peek == '[' && c == ']'){
                    stack.pop();
                }
                else {
                    System.out.println("false");
                }

            }
        }
        if (stack.isEmpty()) {
            System.out.println("true");
        } else {
            System.out.println("false");
        }
    }
}
